"""
 python的各类运算符
"""

# ------算术运算符------ #
print("1 + 1 = ", 1 + 1)
print("2 - 1 = ", 2 - 1)
print("3 * 3 = ", 3 * 3)
print("4 / 2 = ", 4 / 2)
# 整除
print("11 // 2 = ", 11 // 2)
# 取余数
print("9 % 2 = ", 9 % 2)
# 指数
print("2 ** 2 = ", 2 ** 2)

# ------复合运算符------- #
print("---------------------------")
num = 1
num += 1
print("num += 1:", num)
num -= 1
print("num -= 1:", num)
num *= 4
print("num *= 4:", num)
num /= 2
print("num /= 2:", num)

num = 3
num %= 2
print("num %= 2:", num)
num **= 2
print("num **= 2:", num)
num //= 2
print("num //= 2:", num)

print("--------------比较运算符 == != > < >= <= ---------------")
i1, i2, i3 = 20, 10, 30
print(f"{i1} == {i2}:", i1 == i2)
print(f"{i1} > {i2}:", i1 > i2)
print(f"{i1} != {i2}:", i1 != i2)
print(f"{i2} <= {i3}:", i2 <= i3)

print("----------逻辑运算符 and/or/not or/------------")
n, a = 80, 100
print(f"{n} >= 0 and {n} <= {a}:", n >= 0 and n <= a)
print(f"{n} < 0 or {n} > {a}:", n < 0 or n > a)
print(f"not({n} >= 0 and {n} <= {a}):", not (n >= 0 and n <= a))

print("------------------身份运算符-----------------")
x, y = [1, 2, 3], [1, 2, 3]
print(x is y)
print(x is [1, 2, 3])
x = y
print(x is y)
print("-----------------成员运算符------------------")
x1, y1 = 'one', {'one': 1, 'two': 2}
print(x1 in y1)
print(1 in y1)

x2, y2 = 'Py', 'Python'
print(x2 in y2)

print("-----------------序列运算符-----------------")
l1, l2 = [12, False], ['abc', 15, True]
z = l1 + l2
print(z)

s1, s2 = '我爱', 'Python'
s = s1 + s2
print(s)

s_3 = s * 3
print(s_3)
print("-----------运算符优先级----------------------")
print(3 * 5 ** 2)
